package com.ygq.seckill.vo;

import com.baomidou.mybatisplus.extension.api.R;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class RespBean {

    private Integer code;
    private String message;
    private Object object;

    //成功且携带数据
    public static RespBean success (Object data)
    {
        return new RespBean(RespBeanEnum.SUCCESS.getCode(),
                RespBeanEnum.SUCCESS.getMessage(), data);
    }

    public static RespBean success(){
        return new RespBean(RespBeanEnum.SUCCESS.getCode(),
                RespBeanEnum.SUCCESS.getMessage(),null);
    }

    //失败-返回各种失败信息,但不携带数据
    public static RespBean error(RespBeanEnum respBeanEnum){
        return new RespBean(respBeanEnum.getCode(),respBeanEnum.getMessage(), null);
    }

    //失败携带数据
    public static RespBean error(RespBeanEnum respBeanEnum,Object data){
        return new RespBean(respBeanEnum.getCode(),respBeanEnum.getMessage(),data);
    }
    // 获取携带数据

}
